//
//  TextFieldView.m
//  SHHCPhone
//
//  Created by sheng long on 14-6-17.
//  Copyright (c) 2014年 sheng long. All rights reserved.
//

#import "TextFieldView.h"

@implementation TextFieldView

@synthesize textField;

-(void)setBgImage:(NSString*)bgImageName titleImage:(NSString*)titleImageName tip:(NSString*)tip
{
    UIImageView *bgImge = [[UIImageView alloc] initWithImage:[UIImage imageNamed:bgImageName]];
    [bgImge sizeToFit];
    [self addSubview:bgImge];
    [self setFrame:bgImge.bounds];
    
    if (titleImageName) {
        UIImageView* titleImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:titleImageName]];
        [titleImage sizeToFit];
        [titleImage setCenter:CGPointMake(20.5, self.frame.size.height/2)];
        [self addSubview:titleImage];
    }
    
    CGRect rect;
    if (titleImageName) {
        rect = CGRectMake(50, 0, self.frame.size.width-50, self.frame.size.height);
    }else{
        rect = CGRectMake(10, 0, self.frame.size.width-20, self.frame.size.height);
    }
    
    textField = [[CustomTextField alloc] initWithFrame:rect];
    [textField setPlaceholder:tip];
    [self addSubview:textField];
}

@end
